import omit from 'lodash/omit'
import { ManageVideonumsInner } from '@/desktop/components/ManageVideonums'
import type { VideonumWord } from '@/services/common/definition'
import type { SavedVideonum } from '@/services/resources/videonums'
import './index.module.less'

export default function EditVideonum(props: {
  word: VideonumWord
  onSave: (item: VideonumWord) => void
  onCancel: () => void
}) {
  const { word: initialWord, onSave, onCancel } = props
  const onChoose = (choosed: SavedVideonum) =>
    onSave({ ...initialWord, ...omit(choosed, 'id', 'type') })
  return <ManageVideonumsInner onClose={onCancel} choose={{ text: '选择', action: onChoose }} />
}
